#include <iostream>
#include <ostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;

static ostream *log = &cerr;
void set_logfile(char * name /* = "stderr.txt" */)
{
    ofstream *tmp = new ofstream;
    tmp->open(name);
    log = tmp;
}

void log_error(const char * error)
{
    *log<<"ERROR: "<<error<<endl;
    return;
}
        
void log_message(const char * message)
{
    *log<<message<<endl;
    return;
}

void log_error(const string & error)
{
    *log<<"ERROR: "<<error<<endl;
    return;
}

void log_message(const string & message)
{
    *log<<message<<endl;
    return;
}

void log_error(const stringstream & error)
{
    *log<<"ERROR: "<<error.str()<<endl;
    return;
}

void log_message(const stringstream & message)
{
    *log<<message.str()<<endl;
    return;
}
